/**
 * 赢法矩阵，存储所有572种赢法
 * 黑白棋赢法数组，记录每种赢法的完成度
 * 棋子矩阵，存储落点是否可行
 */
// winMatrix;
var winMatrix = [];
var counts = 0;
// black and white
var black = [];
var white = [];
// pieceMatrix;
var pieceMatrix = [];

function initData(){
    winMatrix = [];
    counts = 0;
    black = [];
    white = [];
    pieceMatrix = [];

    // 初始化
    for(let i = 0; i < lineCounts; i++){
        winMatrix[i] = [];
        for(let j = 0; j < lineCounts; j++){
            winMatrix[i][j] = [];
        }
    }

    // 横向
    for(let i = 0; i < lineCounts; i++){
        for(let j = 0; j <= lineCounts - conJunctions; j++){
            // 选择到合适的起始点，加5次即可
            for(let k = 0; k < conJunctions; k++){
                winMatrix[i][j + k][counts] = true;
            }
            counts++;
        }
    }

    // 竖向
    for(let i = 0; i <= lineCounts - conJunctions; i++){
        for(let j = 0; j < lineCounts; j++){
            // 选择到合适的起始点，加5次即可
            for(let k = 0; k < conJunctions; k++){
                winMatrix[i + k][j][counts] = true;
            }
            counts++;
        }
    }

    // 正斜向[\]
    for(let i = 0; i <= lineCounts - conJunctions; i++){
        for(let j = 0; j <= lineCounts - conJunctions; j++){
            // 选择到合适的起始点，加5次即可
            for(let k = 0; k < conJunctions; k++){
                winMatrix[i + k][j + k][counts] = true;
            }
            counts++;
        }
    }

    // 反斜向[/]
    for(let i = 0; i <= lineCounts - conJunctions; i++){
        for(let j = conJunctions - 1; j < lineCounts; j++){
            // 选择到合适的起始点，加5次即可
            for(let k = 0; k < conJunctions; k++){
                winMatrix[i + k][j - k][counts] = true;
            }
            counts++;
        }
    }

    // 黑白棋赢法统计
    for(let i = 0; i < counts; i++){
        black[i] = 0;
        white[i] = 0;
    }

    // 落子矩阵
    for (let i = 0; i < lineCounts; i++) {
        pieceMatrix[i] = [];
        for (let j = 0; j < lineCounts; j++) {
            pieceMatrix[i][j] = true;
        }
    }
}
